package com.yj.inventory.mapper;

import com.yj.inventory.entity.InventoryHistory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Copyright 2017 (C) Yunjian-VC
 * Created on : 2017/12/12
 * Author     : Unbelievable9
 **/
@Repository
@Mapper
public interface InventoryHistoryMapper {

    @Insert("INSERT INTO inventory_history (inventory_id, amount, update_time) " +
            "VALUES(#{item.inventory_id}, #{item.amount}, #{item.update_time})")
    void insert(@Param("item") InventoryHistory inventoryHistory);


    @Select("SELECT * FROM inventory_history WHERE inventory_id = #{inventory_id} ORDER BY update_time DESC")
    List<InventoryHistory> getByInventoryID(@Param("inventory_id") Integer inventory_id);
}
